/**
 * 初始化页面
 */
var parent_id = null;
var parent_name = null;
var parent_ordersall = null;
var moduleTree = null;
var selectedID = null;
function initPage() {
    win.crebtn('moduleTree_btnCancel', '关闭', win.close);
    win.crebtn('moduleTree_btnSave', '确定', save);
    parent_id = myTools.getQueryString("RTN_ID");
    parent_name = myTools.getQueryString("RTN_NAME");
    parent_ordersall = myTools.getQueryString("RTN_ORDERSALL");
    selectedID = myTools.getQueryString("selectedID");
    getModuleTree();
}
function getModuleTree() {
    var json = {
        url:contextPath +"/server/sys/getModuleTree.do",
        msg:"数据加载中.....",
        params:{
            "MODULE_DM_SJ":"-1",//-1 根
            "YXBZ":"1",
            "LX":"0"
        },
        callback:[getModuleTreeByCallBack]
    };
    AjaxTools.ajax(json);
}
function getModuleTreeByCallBack(data) {
    moduleTree = new dhtmlXTreeObject(document.getElementById('treeBox'), "100%", "100%", 0);
    moduleTree.setImagePath("../../include/js/components/xTree/xTree_imgs/csh_bluebooks/");
    moduleTree.enableCheckBoxes(true);
    // moduleTree.enableThreeStateCheckboxes(true);
    moduleTree.loadXMLString(data.data);
    moduleTree.closeAllItems(0);
    moduleTree.setCheck(selectedID, 1);
    moduleTree.openItem(selectedID);
}
/**
 *选择模块
 */
function save() {
    var ids = moduleTree.getAllChecked();
    if (ids.split(",").length > 1) {
        alert("只能选择一个模块");
        return;
    }
    var id = ids.split("-")[0];
    var ordersall = ids.split("-")[1];
    var module_name = moduleTree.getItemText(ids);
    window.parent.parent.document.getElementById(parent_id).value = id;
    window.parent.parent.document.getElementById(parent_name).value = module_name;
    window.parent.parent.document.getElementById(parent_ordersall).value = ordersall;
    win.close();
}
